<template>
	<div id="enterpriseList">
		<el-row style="margin-bottom: 20px;">
			<el-col :span="4">
				<el-input
					suffix-icon="el-icon-search"
					placeholder="搜索"
					size="small"
					v-model="listQuery.searchValue"
				></el-input>
			</el-col>
			<el-col :span="20" style="text-align: right">
				
				<el-button
					size="small"
					type="primary"
					icon="el-icon-search"
					@click="search"
					>搜索</el-button
				>
			</el-col>
		</el-row>
		<Table
			:tableData="tableData"
			:tableHead="tableHead"
			:isUseSlot="false"
			:page="listQuery.page"
			:limit="listQuery.limit"
			v-loading="listLoading"
		>
			<template slot="tool" slot-scope="{ data }">
				<el-button
					style="padding:3px;"
					icon="el-icon-document"
					@click="handleEdit(data.row)"
					type="text"
					>查看</el-button
				>
			</template>
		</Table>
		<Pagination
			v-show="total > 0"
			:total="total"
			:page.sync="listQuery.page"
			:limit.sync="listQuery.limit"
			@pagination="getList"
		></Pagination>
	</div>
</template>

<script>
import Table from "@/components/Table";
import Pagination from "@/components/Pagination"; // 分页
import { getEntList } from "@/api/RCIM/RCIM-archives";
import { deleteEntInfo } from '@/api/RCIM/RCIM-delet';
export default {
	components: {
		Table,
		Pagination
	},
	data() {
		return {
			tableData: [
			],
			tableHead: [
				{
					prop: "enterprise",
					label: "企业",
					width: "",
					align: "left"
				},
				{
					prop: "area",
					label: "所属区域",
					width: "",
					align: "center"
				},
				{
					prop: "enterpriseType",
					label: "企业类型",
					width: "",
					align: "center"
				},
				{
					prop: "address",
					label: "地址",
					width: "",
					align: "center"
				},
				{
					prop: "operate",
					label: "操作",
					width: "",
					align: "center"
				}
			],
			listLoading: false,
			total: 0,
			listQuery: {
				page: 1,
				limit: 10,
				id: "",
				searchValue: '',
			},
		};
	},
	mounted() {
		this.getList()
	},
	methods: {
		/**
		 * @desc 删除列表数据
		 * @param {Object} row 表格行数据
		 */
		delet(row){
			this.$confirm('确认要删除吗？')
				.then(_ => {
					deleteEntInfo(row.id).then(res => {
						if(res.code === 200){
							this.getList()
							return this.$message({
								type: "success",
								message: "删除成功"
							})
						}
						return this.$message({
							type: "error",
							message: "删除失败"
						})
					})
				})
				.catch(_ => {});
		},
		/**
		 * @desc 搜索表格数据
		 */
		search(){
			this.listQuery.page = 1
			this.getList()
		},
		/**
		 * @desc 获取表格数据
		 */
		async getList() {
			this.listLoading = true;
			const { data } = await getEntList(this.listQuery);
			this.total = data.total;
			this.tableData = data.enterpriseList;
			this.listLoading = false;
		},
		/**
		 * @desc 查看表格详情
		 */
		handleEdit(row) {
            this.$emit("toDetail", row);
        },
		/**
		 * @desc 新增表格数据
		 */
		handleAdd() {
			this.$emit("toDetail");
		},
		submit(formData) {},
		closeDialog() {}
	}
};
</script>

<style lang="scss" scoped>
#enterpriseList {
	height: calc(100vh - 144px);
	overflow: hidden;
	padding: 30px 50px;
}
</style>
